
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>第七章：运算符 ·  GO语言 web服务器区块链开发工程师就业班课程</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="波波">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-sectionx/sectionx.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-navigator/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../Chapter8/流程控制.html" />
    
    
    <link rel="prev" href="../Chapter6/常量.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://www.shxdledu.cn/single/About-Me" target="_blank" class="custom-link">关于作者</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Chapter1/base.html">
            
                <a href="../Chapter1/base.html">
            
                    
                    第一章：区块链基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../Chapter2/base.html">
            
                <a href="../Chapter2/base.html">
            
                    
                    第二章：初识Go语言
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../Chapter2/GO语言介绍.html">
            
                <a href="../Chapter2/GO语言介绍.html">
            
                    
                    第1节：GO语言介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../Chapter2/环境安装.html">
            
                <a href="../Chapter2/环境安装.html">
            
                    
                    第2节：环境安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../Chapter2/第一个GO程序.html">
            
                <a href="../Chapter2/第一个GO程序.html">
            
                    
                    第3节：第一个GO程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../Chapter2/学习资料.html">
            
                <a href="../Chapter2/学习资料.html">
            
                    
                    第4节：学习资料
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../Chapter3/注释.html">
            
                <a href="../Chapter3/注释.html">
            
                    
                    第三章：注释
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../Chapter3/注释作用.html">
            
                <a href="../Chapter3/注释作用.html">
            
                    
                    第1节：注释作用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../Chapter3/注释分类.html">
            
                <a href="../Chapter3/注释分类.html">
            
                    
                    第2节：注释分类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../Chapter3/学习资料.html">
            
                <a href="../Chapter3/学习资料.html">
            
                    
                    第3节：学习资料
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../Chapter4/变量.html">
            
                <a href="../Chapter4/变量.html">
            
                    
                    第四章：变量
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../Chapter4/什么叫变量.html">
            
                <a href="../Chapter4/什么叫变量.html">
            
                    
                    第1节：什么叫变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../Chapter4/变量类型.html">
            
                <a href="../Chapter4/变量类型.html">
            
                    
                    第2节：变量类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../Chapter4/变量声明.html">
            
                <a href="../Chapter4/变量声明.html">
            
                    
                    第3节：变量声明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../Chapter4/变量初始化.html">
            
                <a href="../Chapter4/变量初始化.html">
            
                    
                    第4节：变量初始化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../Chapter4/变量赋值.html">
            
                <a href="../Chapter4/变量赋值.html">
            
                    
                    第5节：变量赋值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../Chapter4/自动推导类型.html">
            
                <a href="../Chapter4/自动推导类型.html">
            
                    
                    第6节：自动推导类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="../Chapter4/多重赋值匿名变量.html">
            
                <a href="../Chapter4/多重赋值匿名变量.html">
            
                    
                    第7节：多重赋值匿名变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="../Chapter4/数据置换.html">
            
                <a href="../Chapter4/数据置换.html">
            
                    
                    第8节：数据置换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9" data-path="../Chapter4/输出格式.html">
            
                <a href="../Chapter4/输出格式.html">
            
                    
                    第9节：输出格式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.10" data-path="../Chapter4/接收输入.html">
            
                <a href="../Chapter4/接收输入.html">
            
                    
                    第10节：接收输入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.11" data-path="../Chapter4/变量命名规范.html">
            
                <a href="../Chapter4/变量命名规范.html">
            
                    
                    第11节：变量命名规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.12" data-path="../Chapter4/变量命名规范.html">
            
                <a href="../Chapter4/变量命名规范.html">
            
                    
                    第12节：变量命名规范
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../Chapter5/基础数据类型.html">
            
                <a href="../Chapter5/基础数据类型.html">
            
                    
                    第五章：基础数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../Chapter6/常量.html">
            
                <a href="../Chapter6/常量.html">
            
                    
                    第六章：常量
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.8" data-path="运算符.html">
            
                <a href="运算符.html">
            
                    
                    第七章：运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../Chapter8/流程控制.html">
            
                <a href="../Chapter8/流程控制.html">
            
                    
                    第八章：流程控制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../Chapter9/函数.html">
            
                <a href="../Chapter9/函数.html">
            
                    
                    第九章：函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../Chapter10/工程管理.html">
            
                <a href="../Chapter10/工程管理.html">
            
                    
                    第十章：工程管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../Chapter11/数据格式.html">
            
                <a href="../Chapter11/数据格式.html">
            
                    
                    第十一章：数据格式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../Chapter12/面向对象.html">
            
                <a href="../Chapter12/面向对象.html">
            
                    
                    第十二章：面向对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../Chapter13/异常处理.html">
            
                <a href="../Chapter13/异常处理.html">
            
                    
                    第十三章：异常处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../Chapter14/文本文件处理.html">
            
                <a href="../Chapter14/文本文件处理.html">
            
                    
                    第十四章：文本文件处理
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >第七章：运算符</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x7B2C;&#x4E03;&#x7AE0;&#xFF1A;&#x8FD0;&#x7B97;&#x7B26;">&#x7B2C;&#x4E03;&#x7AE0;&#xFF1A;&#x8FD0;&#x7B97;&#x7B26;</h1>
<p>&#x5728;&#x524D;&#x9762;&#x7684;&#x8BFE;&#x7A0B;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x5B66;&#x4E60;&#x4E86;&#x53D8;&#x91CF;&#xFF0C;&#x5E38;&#x91CF;&#xFF0C;&#x90A3;&#x4E48;&#x63A5;&#x4E0B;&#x6765;&#x6211;&#x4EEC;&#x5B66;&#x4E60;&#x4E00;&#x4E0B;&#x8FD0;&#x7B97;&#x7B26;&#x3002;GO&#x8BED;&#x8A00;&#x4E2D;&#x5E38;&#x89C1;&#x7684;&#x8FD0;&#x7B97;&#x7B26;&#x6709;&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;&#xFF0C;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;&#xFF0C;&#x5173;&#x7CFB;&#x8FD0;&#x7B97;&#x7B26;&#xFF0C;&#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;&#x7B49;&#x3002;</p>
<h2 id="1&#xFF1A;&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;">1. 1&#xFF1A;&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;</h2>
<table>
<thead>
<tr>
<th style="text-align:center">&#x8FD0;&#x7B97;&#x7B26;</th>
<th style="text-align:center">&#x672F;&#x8BED;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">+</td>
<td style="text-align:center">&#x52A0;</td>
</tr>
<tr>
<td style="text-align:center">-</td>
<td style="text-align:center">&#x51CF;</td>
</tr>
<tr>
<td style="text-align:center">*</td>
<td style="text-align:center">&#x4E58;</td>
</tr>
<tr>
<td style="text-align:center">/</td>
<td style="text-align:center">&#x9664;</td>
</tr>
<tr>
<td style="text-align:center">%</td>
<td style="text-align:center">&#x53D6;&#x6A21;(&#x53D6;&#x4F59;)</td>
</tr>
<tr>
<td style="text-align:center">++</td>
<td style="text-align:center">&#x540E;&#x81EA;&#x589E;&#xFF0C;&#x6CA1;&#x6709;&#x524D;&#x81EA;&#x589E;</td>
</tr>
<tr>
<td style="text-align:center">--</td>
<td style="text-align:center">&#x540E;&#x81EA;&#x51CF;&#xFF0C;&#x6CA1;&#x6709;&#x524D;&#x81EA;&#x51CF;</td>
</tr>
</tbody>
</table>
<pre class="language-"><code>package main

import &quot;fmt&quot;

func main0701() {
    a := 10
    b := 5

    fmt.Println(a + b) //30
    fmt.Println(a - b) //-10
    fmt.Println(a * b) //200
    //&#x4E24;&#x4E2A;&#x6574;&#x6570;&#x76F8;&#x9664;&#x7B49;&#x5230;&#x7684;&#x7ED3;&#x679C;&#x4E5F;&#x662F;&#x6574;&#x578B;
    //&#x5728;&#x9664;&#x6CD5;&#x8BA1;&#x7B97;&#x65F6; &#x9664;&#x6570;&#x4E0D;&#x80FD;&#x4E3A;0
    fmt.Println(a / b) //???0

    //&#x901A;&#x8FC7;&#x547D;&#x4EE4;&#x7F16;&#x8BD1;&#x4EE3;&#x7801;
    //go build &#x6E90;&#x6587;&#x4EF6;1.go &#x6E90;&#x6587;&#x4EF6;2.go
    //&#x7F16;&#x8BD1;&#x5E76;&#x8FD0;&#x884C;&#x7A0B;&#x5E8F;
    //go run &#x6E90;&#x6587;&#x4EF6;1.go &#x6E90;&#x6587;&#x4EF6;2.go
    //&#x5F02;&#x5E38;
    /*
    1&#x3001;&#x7F16;&#x8F91;&#x65F6;&#x5F02;&#x5E38;
    2&#x3001;&#x7F16;&#x8BD1;&#x65F6;&#x5F02;&#x5E38;
    3&#x3001;&#x8FD0;&#x884C;&#x65F6;&#x5F02;&#x5E38;
     */
}
func main0702() {
    a := 10
    b := 2
    //&#x53D6;&#x4F59;&#x8FD0;&#x7B97;&#x7B26;&#x9664;&#x6570;&#x4E0D;&#x80FD;&#x4E3A;0
    //&#x53D6;&#x4F59;&#x8FD0;&#x7B97;&#x7B26;&#x4E0D;&#x80FD;&#x5BF9;&#x6D6E;&#x70B9;&#x578B;&#x4F7F;&#x7528;
    c := a % b
    fmt.Println(c)
}

func main() {
    //&#x81EA;&#x589E;&#x81EA;&#x51CF;&#x8FD0;&#x7B97;&#x7B26;
    //&#x53EF;&#x4EE5;&#x5BF9;&#x6D6E;&#x70B9;&#x578B;&#x8FDB;&#x884C;&#x81EA;&#x589E;&#x81EA;&#x51CF;&#x8FD0;&#x7B97; &#x4F46;&#x662F;&#x4E0D;&#x80FD;&#x5BF9;&#x5E38;&#x91CF;&#x8FDB;&#x884C;&#x81EA;&#x589E;&#x81EA;&#x51CF;&#x8FD0;&#x7B97;
    a := 10
    //const a =10
    //a = a + 1
    //a++//&#x81EA;&#x589E; &#x5728;&#x53D8;&#x91CF;&#x672C;&#x8EAB;&#x52A0;&#x4E00;

    //a--//&#x81EA;&#x51CF;

    //&#x81EA;&#x589E;&#x81EA;&#x51CF;&#x4E0D;&#x80FD;&#x51FA;&#x73B0;&#x5728;&#x8868;&#x8FBE;&#x5F0F;&#x4E2D;
    //a = a++ + a--
    //&#x4E8C;&#x4E49;&#x6027; &#x5728;&#x4E0D;&#x540C;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x4E2D;&#x8FD0;&#x7B97;&#x65B9;&#x5F0F;&#x4E0D;&#x540C; &#x7ED3;&#x679C;&#x53EF;&#x80FD;&#x4F1A;&#x4EA7;&#x751F;&#x504F;&#x5DEE;
    //a = a++ * a-- - a--//err
    //b:=a--//err

    fmt.Println(a)
    //fmt.Println(b)
}
</code></pre><h2 id="2&#xFF1A;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#xFF1A;">2. 2&#xFF1A;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#xFF1A;</h2>
<pre class="language-"><code>package main

import &quot;fmt&quot;

func main0801() {

    a, b, c := 0, 0, 0

    fmt.Scan(&amp;a, &amp;b, &amp;c)

    sum := a + b + c
    fmt.Println(sum)
    //&#x7C7B;&#x578B;&#x8F6C;&#x6362; &#x6570;&#x636E;&#x7C7B;&#x578B;(&#x53D8;&#x91CF;)  &#x6570;&#x636E;&#x7C7B;&#x578B;(&#x8868;&#x8FBE;&#x5F0F;)
    //fmt.Println(float64(sum / 3))
    fmt.Printf(&quot;%.2f&quot;, float64(sum)/3)
}

func main0802() {
    //var a float32 = 12.34
    //var b float64 = 22.22

    //int8 -&gt; int16 -&gt;int32 -&gt;int64
    //float32 -&gt;float64

    //int64 -&gt; float64
    //&#x5728;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x65F6;&#x5EFA;&#x8BAE;&#x4F4E;&#x7C7B;&#x578B;&#x8F6C;&#x6210;&#x9AD8;&#x7C7B;&#x578B;  &#x4FDD;&#x8BC1;&#x6570;&#x636E;&#x7CBE;&#x5EA6;
    //&#x5EFA;&#x8BAE;&#x6574;&#x578B;&#x8F6C;&#x6210;&#x6D6E;&#x70B9;&#x578B;
    //&#x9AD8;&#x7C7B;&#x578B;&#x8F6C;&#x6210;&#x4F4E;&#x7C7B;&#x578B; &#x53EF;&#x80FD;&#x4F1A;&#x4E22;&#x5931;&#x7CBE;&#x5EA6;
    //fmt.Printf(&quot;%.2f&quot;, float64(a)+b)

    //fmt.Println(float64(a) + b)

    //&#x6570;&#x636E;&#x6EA2;&#x51FA; &#x7B26;&#x53F7;&#x53D1;&#x751F;&#x53D8;&#x5316;
    //var a int = 1234
    //fmt.Println(int8(a))
    var a float64 = 3.999

    //&#x5C06;&#x6D6E;&#x70B9;&#x578B;&#x8F6C;&#x6210;&#x6574;&#x578B; &#x4FDD;&#x7559;&#x6570;&#x636E;&#x6574;&#x6570;&#x90E8;&#x5206; &#x4E22;&#x5F03;&#x5C0F;&#x6570;&#x90E8;&#x5206;
    b := int(a) //3
    fmt.Println(b)
}

//&#x7EC3;&#x4E60;&#x9898;
func main() {
    //107653&#x51E0;&#x5929;&#x51E0;&#x5C0F;&#x65F6;&#x51E0;&#x5206;&#x51E0;&#x79D2;

    s := 107653

    fmt.Println(&quot;&#x5929;&#xFF1A;&quot;, s/60/60/24%365)
    fmt.Println(&quot;&#x65F6;&#xFF1A;&quot;, s/60/60%24)
    fmt.Println(&quot;&#x5206;&#xFF1A;&quot;, s/60%60)
    fmt.Println(&quot;&#x79D2;&#xFF1A;&quot;, s%60)

    //1*24*60*60 + 5*60*60 + 54*60 + 13 =107653
}
</code></pre><h2 id="3&#xFF1A;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;">3. 3&#xFF1A;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;</h2>
<pre class="language-"><code>package main

import &quot;fmt&quot;

func main() {
    //a := 10
    //b := 20
    //c := a + b
    //
    ////c += 20 //c=c+20
    ////c -= 20
    ////c *= 20
    ////c /= 20 //30
    //c = 20
    //c %= 3 //c = c % 3

    var c int = 10
    //&#x5C06;&#x8868;&#x8FBE;&#x5F0F;&#x53F3;&#x4FA7;&#x8FDB;&#x884C;&#x7ED3;&#x679C;&#x8BA1;&#x7B97;&#x5728;&#x8FDB;&#x884C;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;
    c %= (2 + 3)

    //c = c % 5 //ok
    //c = c % 2 + 3//err

    fmt.Println(c)
}
</code></pre><h2 id="4&#xFF1A;&#x5173;&#x7CFB;(&#x6BD4;&#x8F83;)&#x8FD0;&#x7B97;&#x7B26;">4. 4&#xFF1A;&#x5173;&#x7CFB;(&#x6BD4;&#x8F83;)&#x8FD0;&#x7B97;&#x7B26;</h2>
<p>&#x5173;&#x7CFB;&#x8FD0;&#x7B97;&#x7B26;&#x6211;&#x4EEC;&#x53C8;&#x79F0;&#x4E3A;&#x6BD4;&#x8F83;&#x8FD0;&#x7B97;&#x7B26;&#xFF0C;&#x542C;&#x5230;&#x6BD4;&#x8F83;&#x8FD9;&#x4E2A;&#x8BCD;&#xFF0C;&#x5927;&#x5BB6;&#x60F3;&#x5230;&#x7684;&#x5C31;&#x662F;&#x6BD4;&#x8F83;&#x5927;&#x5C0F;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;
&#x5927;&#x8C61;&#x7684;&#x91CD;&#x91CF;(1500)&gt;&#x8001;&#x9F20;&#x7684;&#x91CD;&#x91CF;(1)
&#x5154;&#x5B50;&#x7684;&#x5BFF;&#x547D;(3)&gt;&#x4E4C;&#x9F9F;&#x7684;&#x5BFF;&#x547D;(1000)
&#x6211;&#x7684;&#x5E74;&#x9F84;(20)==&#x4F60;&#x7684;&#x5E74;&#x9F84;(20)
&#x63D0;&#x95EE;&#xFF1A;&#x6BD4;&#x5927;&#x6BD4;&#x5C0F;&#x7684;&#x7ED3;&#x679C;&#x662F;&#x4EC0;&#x4E48;&#xFF1F;
&#x7ED3;&#x679C;&#x662F;&#x5BF9;&#x6216;&#x8005;&#x662F;&#x9519;&#xFF0C;&#x5728;GO&#x8BED;&#x8A00;&#x4E2D;&#xFF0C;&#x600E;&#x6837;&#x8868;&#x793A;&#x5BF9;&#x4E8E;&#x9519;&#x5462;&#xFF1F;
&#x5173;&#x7CFB;&#x8FD0;&#x7B97;&#x7684;&#x7ED3;&#x679C;&#x662F;&#x5E03;&#x5C14;&#x7C7B;&#x578B;&#x7684;&#x3002;
bool&#x503C;&#x53EA;&#x6709;&#x4E24;&#x4E2A;
&#x771F;:true
&#x5047;:false</p>
<pre class="language-"><code>package main

import &quot;fmt&quot;

func main1001() {

    //&#x6BD4;&#x8F83;&#x8FD0;&#x7B97;&#x7B26;&#x8FD4;&#x56DE;&#x503C;bool&#x7C7B;&#x578B;
    a := 10
    b := 10

    //&#x5927;&#x4E8E; &gt;  &#x5C0F;&#x4E8E; &lt;
    //fmt.Println(a &lt; b)
    //&#x5927;&#x4E8E;&#x7B49;&#x4E8E; &gt;= &#x5C0F;&#x4E8E;&#x7B49;&#x4E8E; &lt;=
    //fmt.Println(a &lt; b)
    //&#x76F8;&#x7B49;&#x4E8E; ==  &#x4E0D;&#x7B49;&#x4E8E; !=
    fmt.Println(a != b)
}

func main() {
    //a := 10
    //b := 20
    //
    ////&#x6BD4;&#x8F83;&#x8FD0;&#x7B97;&#x7B26;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x4E3A;bool&#x7C7B;&#x578B;
    //c := a + 20 &gt; b
    //
    //fmt.Printf(&quot;%T\n&quot;, c)
    //fmt.Println(c)
    a := &apos;a&apos;
    b := &apos;A&apos;

    fmt.Println(a &gt; b)
}
</code></pre><h2 id="5&#xFF1A;&#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;">5. 5&#xFF1A;&#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;</h2>
<p>1&#xFF09;&#x5E38;&#x89C1;&#x7684;&#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;&#x5982;&#x4E0B;&#xFF1A;
<img src="https://leanote.com/api/file/getImage?fileId=5dc199e7ab6441404f00068e" alt="title"></p>
<p>&#x6709;&#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;&#x8FDE;&#x63A5;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x53EB;&#x505A;&#x903B;&#x8F91;&#x8868;&#x8FBE;&#x5F0F;
&#x901A;&#x8FC7;&#x4EE5;&#x4E0A;&#x8868;&#x683C;&#x6211;&#x4EEC;&#x53D1;&#x73B0;&#xFF1A;&#x903B;&#x8F91;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x7ED3;&#x679C;&#x540C;&#x6837;&#x4E5F;&#x662F;bool&#x7C7B;&#x578B;
&#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;&#x4E24;&#x8FB9;&#x653E;&#x7684;&#x4E00;&#x822C;&#x90FD;&#x662F;&#x5173;&#x7CFB;&#x8868;&#x8FBE;&#x5F0F;&#x6216;&#x8005;bool&#x7C7B;&#x578B;&#x7684;&#x503C;&#x3002;
&#x4F8B;&#x5982;&#xFF1A;
5&gt;3 &amp;&amp;true 
  3&gt;5||false</p>
<pre class="language-"><code>package main

import &quot;fmt&quot;

func main1101() {

    a := 10
    b := 20

    //c := a &gt; b //flase

    //&#x903B;&#x8F91;&#x975E; !  &#x975E;&#x771F;&#x4E3A;&#x5047; &#x975E;&#x5047;&#x4E3A;&#x771F;
    fmt.Println(!(a &gt; b))
    //&#x5355;&#x76EE;&#x8FD0;&#x7B97;&#x7B26;
    // ! ++ -- &amp;(&#x53D6;&#x5730;&#x5740;&#x8FD0;&#x7B97;&#x7B26;)
    //&#x53CC;&#x76EE;&#x8FD0;&#x7B97;&#x7B26;

}

func main1102() {

    a := 10
    b := 20

    //&#x903B;&#x8F91;&#x4E0E;  &amp;&amp;  &#x540C;&#x771F;&#x4E3A;&#x771F; &#x5176;&#x4F59;&#x4E3A;&#x5047;

    c := a &lt; b &amp;&amp; false
    fmt.Println(c)

}

func main1103() {
    a := 10
    b := 20
    //&#x903B;&#x8F91;&#x6216;  ||  &#x540C;&#x5047;&#x4E3A;&#x5047; &#x5176;&#x4F59;&#x4E3A;&#x771F;
    fmt.Println(a &lt; b || a &gt; b)
}

func main() {
    a := 10
    b := 20

    //&#x903B;&#x8F91;&#x4E0E;&#x9AD8;&#x4E8E;&#x903B;&#x8F91;&#x6216;
    fmt.Println(a &gt; b &amp;&amp; b &gt; a || a &gt; 0)
}
</code></pre><h2 id="6&#xFF1A;&#x5176;&#x4ED6;&#x8FD0;&#x7B97;&#x7B26;">6. 6&#xFF1A;&#x5176;&#x4ED6;&#x8FD0;&#x7B97;&#x7B26;</h2>
<table>
<thead>
<tr>
<th style="text-align:left">&#x8FD0;&#x7B97;&#x7B26;</th>
<th style="text-align:right">&#x672F;&#x8BED;</th>
<th style="text-align:center">&#x793A;&#x4F8B;</th>
<th style="text-align:center">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">&amp;</td>
<td style="text-align:right">&#x53D6;&#x5730;&#x5740;&#x8FD0;&#x7B97;&#x7B26;</td>
<td style="text-align:center">&amp;a</td>
<td style="text-align:center">&#x53D8;&#x91CF;a&#x7684;&#x5730;&#x5740;</td>
</tr>
<tr>
<td style="text-align:left">*</td>
<td style="text-align:right">&#x53D6;&#x503C;&#x8FD0;&#x7B97;&#x7B26;</td>
<td style="text-align:center">*a</td>
<td style="text-align:center">&#x6307;&#x9488;&#x53D8;&#x91CF;a&#x6240;&#x6307;&#x5411;&#x5185;&#x5B58;&#x7684;&#x503C;</td>
</tr>
</tbody>
</table>
<p>&#x4F20;&#x5740;&#xFF1A;&#x4F20;&#x5185;&#x5B58;&#x5757;</p>
<p>&#x4F20;&#x503C;&#xFF1A;&#x4F20;&#x53D8;&#x91CF;&#x503C;&#xFF0C;&#x4E24;&#x4E2A;&#x5185;&#x5B58;&#x5757;</p>
<p>&#x5173;&#x4E8E;&#x6307;&#x9488;&#x7684;&#x5E94;&#x7528;&#xFF0C;&#x6211;&#x4EEC;&#x540E;&#x9762;&#x4F1A;&#x91CD;&#x70B9;&#x7ED9;&#x5927;&#x5BB6;&#x8BB2;&#x89E3;&#xFF0C;&#x76EE;&#x524D;&#x5927;&#x5BB6;&#x53EA;&#x9700;&#x8981;&#x638C;&#x63E1; &amp;</p>
<p>&#x4EE3;&#x7801;&#x770B;&#x4E0B;&#x9762;</p>
<h2 id="7&#xFF1A;&#x8FD0;&#x7B97;&#x7B26;&#x4F18;&#x5148;&#x7EA7;">7. 7&#xFF1A;&#x8FD0;&#x7B97;&#x7B26;&#x4F18;&#x5148;&#x7EA7;</h2>
<p>&#x5728;Go&#x8BED;&#x8A00;&#x4E2D;&#xFF0C;&#x4E00;&#x5143;&#x8FD0;&#x7B97;&#x7B26;&#xFF08;&#x4E00;&#x4E9B;&#x53EA;&#x9700;&#x8981;&#x4E00;&#x4E2A;&#x64CD;&#x4F5C;&#x6570;&#x7684;&#x8FD0;&#x7B97;&#x7B26;&#x79F0;&#x4E3A;&#x4E00;&#x5143;&#x8FD0;&#x7B97;&#x7B26;&#xFF08;&#x6216;&#x5355;&#x76EE;&#x8FD0;&#x7B97;&#x7B26;&#xFF09;&#x3002;&#xFF09;&#x62E5;&#x6709;&#x6700;&#x9AD8;&#x7684;&#x4F18;&#x5148;&#x7EA7;&#xFF0C;&#x4E8C;&#x5143;&#x8FD0;&#x7B97;&#x7B26;&#x7684;&#x8FD0;&#x7B97;&#x65B9;&#x5411;&#x5747;&#x662F;&#x4ECE;&#x5DE6;&#x81F3;&#x53F3;&#x3002;
&#x4E0B;&#x8868;&#x5217;&#x51FA;&#x4E86;&#x6240;&#x6709;&#x8FD0;&#x7B97;&#x7B26;&#x4EE5;&#x53CA;&#x5B83;&#x4EEC;&#x7684;&#x4F18;&#x5148;&#x7EA7;&#xFF0C;&#x7531;&#x4E0A;&#x81F3;&#x4E0B;&#x4EE3;&#x8868;&#x4F18;&#x5148;&#x7EA7;&#x7531;&#x9AD8;&#x5230;&#x4F4E;&#xFF1A;</p>
<p><img src="https://leanote.com/api/file/getImage?fileId=5dc19a9bab6441425d000647" alt="title"></p>
<p>&#x4E0A;&#x56FE;&#x4E2D;&#x90E8;&#x5206;&#x8FD0;&#x7B97;&#x7B26;&#x73B0;&#x5728;&#x6CA1;&#x6709;&#x8BB2;&#x89E3;&#x5230;&#xFF0C;&#x540E;&#x671F;&#x7528;&#x5230;&#x65F6;&#x518D;&#x7ED9;&#x5927;&#x5BB6;&#x5177;&#x4F53;&#x8BB2;&#x89E3;&#xFF0C;&#x76EE;&#x524D;&#x5927;&#x5BB6;&#x9700;&#x8981;&#x638C;&#x63E1;&#x7684;&#x662F;&#x7B97;&#x672F;&#xFF0C;&#x8D4B;&#x503C;&#xFF0C;&#x5173;&#x7CFB;&#xFF0C;&#x903B;&#x8F91;&#xFF0C;&#x53D6;&#x5730;&#x5740;&#x8FD0;&#x7B97;&#x7B26;&#x3002;</p>
<pre class="language-"><code>package main

import &quot;fmt&quot;

func main1201() {

    a := 10

    //&amp; &#x53D6;&#x5730;&#x5740;&#x8FD0;&#x7B97;&#x7B26;
    fmt.Println(&amp;a)

    //* &#x53D6;&#x503C;&#x8FD0;&#x7B97;&#x7B26; p  &#x6307;&#x9488;&#x53D8;&#x91CF;
    p := &amp;a

    //&#x901A;&#x8FC7;&#x6307;&#x9488;&#x95F4;&#x63A5;&#x4FEE;&#x6539;&#x53D8;&#x91CF;&#x7684;&#x503C;
    *p = 123
    fmt.Println(*p)
    fmt.Println(a)


    //()&#x62EC;&#x53F7;&#x8FD0;&#x7B97;&#x7B26;  &#x6700;&#x9AD8;&#x7EA7;
    //[]&#x6570;&#x7EC4;&#x5207;&#x7247;&#x4E0B;&#x6807;
    //. &#x7ED3;&#x6784;&#x4F53;.&#x6210;&#x5458; &#x5305;.&#x51FD;&#x6570; &#x5BF9;&#x8C61;.&#x65B9;&#x6CD5;

    // &#x4F4D;&#x8FD0;&#x7B97;  &amp; | ^ ~ &#x4F4D;&#x79FB;&#x8FD0;&#x7B97; &gt;&gt;  &lt;&lt;

    // &#x901A;&#x4FE1; &gt;-

}

func main(){

    //()&#x62EC;&#x53F7;&#x8FD0;&#x7B97;&#x7B26;  &#x6700;&#x9AD8;&#x7EA7;
    //[]&#x6570;&#x7EC4;&#x5207;&#x7247;&#x4E0B;&#x6807;
    //. &#x7ED3;&#x6784;&#x4F53;.&#x6210;&#x5458; &#x5305;.&#x51FD;&#x6570; &#x5BF9;&#x8C61;.&#x65B9;&#x6CD5;

    //&#x5355;&#x76EE;&#x8FD0;&#x7B97;&#x7B26;
    // !(&#x903B;&#x8F91;&#x975E;) ++(&#x81EA;&#x589E;) --(&#x81EA;&#x51CF;) &amp;(&#x53D6;&#x5730;&#x5740;) *(&#x53D6;&#x503C;)

    //&#x53CC;&#x76EE;&#x8FD0;&#x7B97;&#x7B26;
    //*(&#x4E58;) /(&#x9664;) %(&#x53D6;&#x4F59;)
    //+(&#x52A0;) -(&#x51CF;)
    // &gt;(&#x5927;&#x4E8E;) <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>(&#x5C0F;&#x4E8E;)</span> <span class="token punctuation">&gt;</span></span>=(&#x5927;&#x4E8E;&#x7B49;&#x4E8E;) &lt;=(&#x5C0F;&#x4E8E;&#x7B49;&#x4E8E;) ==(&#x76F8;&#x7B49;&#x4E8E;) !=(&#x4E0D;&#x7B49;&#x4E8E;)
    //&amp;&amp; (&#x903B;&#x8F91;&#x4E0E;)
    //|| (&#x903B;&#x8F91;&#x6216;)
    //= += -= *= /= %=(&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;)


}
</code></pre><footer class="page-footer"><span class="copyright">Copyright &#xA9; shxdledu.cn 2018 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2019-11-07 00:56:21
</span></footer><div id="anchors-navbar"><i class="fa fa-anchor"></i><ul><p><a href="#&#x7B2C;&#x4E03;&#x7AE0;&#xFF1A;&#x8FD0;&#x7B97;&#x7B26;">&#x7B2C;&#x4E03;&#x7AE0;&#xFF1A;&#x8FD0;&#x7B97;&#x7B26;</a></p><li><a href="#1&#xFF1A;&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;">1. 1&#xFF1A;&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;</a></li><li><a href="#2&#xFF1A;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#xFF1A;">2. 2&#xFF1A;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#xFF1A;</a></li><li><a href="#3&#xFF1A;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;">3. 3&#xFF1A;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;</a></li><li><a href="#4&#xFF1A;&#x5173;&#x7CFB;(&#x6BD4;&#x8F83;)&#x8FD0;&#x7B97;&#x7B26;">4. 4&#xFF1A;&#x5173;&#x7CFB;(&#x6BD4;&#x8F83;)&#x8FD0;&#x7B97;&#x7B26;</a></li><li><a href="#5&#xFF1A;&#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;">5. 5&#xFF1A;&#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;</a></li><li><a href="#6&#xFF1A;&#x5176;&#x4ED6;&#x8FD0;&#x7B97;&#x7B26;">6. 6&#xFF1A;&#x5176;&#x4ED6;&#x8FD0;&#x7B97;&#x7B26;</a></li><li><a href="#7&#xFF1A;&#x8FD0;&#x7B97;&#x7B26;&#x4F18;&#x5148;&#x7EA7;">7. 7&#xFF1A;&#x8FD0;&#x7B97;&#x7B26;&#x4F18;&#x5148;&#x7EA7;</a></li></ul></div><a href="#1&#xFF1A;&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;" id="goTop"><i class="fa fa-arrow-up"></i></a>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../Chapter6/常量.html" class="navigation navigation-prev " aria-label="Previous page: 第六章：常量">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../Chapter8/流程控制.html" class="navigation navigation-next " aria-label="Next page: 第八章：流程控制">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"第七章：运算符","level":"1.8","depth":1,"next":{"title":"第八章：流程控制","level":"1.9","depth":1,"path":"Chapter8/流程控制.md","ref":"Chapter8/流程控制.md","articles":[]},"previous":{"title":"第六章：常量","level":"1.7","depth":1,"path":"Chapter6/常量.md","ref":"Chapter6/常量.md","articles":[]},"dir":"ltr"},"config":{"plugins":["toggle-chapters","sectionx","tbfed-pagefooter","include-codeblock","splitter","mermaid","codeblock-filename","prism","-highlight","simple-page-toc","navigator"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy shxdledu.cn 2018","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{},"simple-page-toc":{"maxDepth":3,"skipFirstH1":true},"splitter":{},"search":{},"mermaid":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"sectionx":{},"codeblock-filename":{},"navigator":{},"include-codeblock":{"check":false,"edit":false,"fixlang":false,"lang":"","template":"default","theme":"chrome","unindent":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":true,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{}},"theme":"default","author":"波波","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":" GO语言 web服务器区块链开发工程师就业班课程","language":"zh-hans","links":{"sidebar":{"关于作者":"http://www.shxdledu.cn/single/About-Me"}},"gitbook":"*","description":" GO语言 web服务器区块链开发工程师就业班课程"},"file":{"path":"Chapter7/运算符.md","mtime":"2019-11-06T16:56:21.597Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-11-06T17:01:48.340Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sectionx/sectionx.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

